<template>
  <el-card class="me-area"
           :body-style="{ padding: '16px' }">
    <div class="me-article-header">
      <a class="me-article-title">{{title}}</a>
      <i class="el-icon-star-off" style="cursor: pointer;float: right" @click="dialogVisible = true"/>
      <el-dialog
          title="提示"
          :visible.sync="dialogVisible"
          width="30%"
          :modal="false"
          :before-close="handleClose">
        <span>您确定要收藏此条评论吗？</span>
        <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="setComment(comment_id)">确 定</el-button>
    </span>
      </el-dialog>
    </div>

    <div class="me-artile-description">
      <span class="me-pull-right me-article-count">
            {{commentCounts}}
          </span>
    </div>
    <div class="me-article-footer">
          <span class="me-article-author" style="float: left;margin-bottom: 10px;margin-left: 10px;">
             <i class="el-icon-user"></i>&nbsp;{{author}}
          </span>
      <div class="me-pull-right me-article-time" style="float: right;margin-bottom: 10px;margin-right: 10px;">
          <span class="me-pull-right me-article-count">
            <i class="el-icon-time"></i>&nbsp;{{createDate}}
          </span>
      </div>
    </div>
  </el-card>
</template>
<script>
export default {
  name: "art",
  props: {
    book_name:String,
    comment_id: Number,
    title: String,
    commentCounts: String,
    author: String,
    author_id: Number,
    createDate: String,
  },

  data() {
    return {
      imgList: [],
      dialogVisible:false
    };
  },
  mounted() {
  },
  methods: {
    handleClose(done) {
      this.$confirm('确认关闭？')
          .then(_ => {
            done();
          })
          .catch(_ => {});
    },
    setComment(id){
      this.dialogVisible = false
      this.$axios
          .post('/setComment', {
            commentId: id,
            userId:window.localStorage.getItem('userId')
          })
          .then(res=>{
            if(res=='0'){
              this.$message({
                message: '收藏成功',
                type: 'success'
              });
            }else{
              this.$message('您已经收藏');
            }
          })
    }
  },
};
</script>

<style scoped >
.me-article-footer{
  margin-top: 30px;
}
.me-article-header {
  /*padding: 10px 18px;*/
  padding-bottom: 10px;
}

.me-article-title {
  font-weight: 600;
}

.me-article-icon {
  padding: 3px 8px;
}

.me-article-count {
  color: #a6a6a6;
  padding-left: 10px;
  font-size: 13px;
  float: left;
}

.me-artile-description {
  font-size: 13px;
  line-height: 24px;
  margin-bottom: 10px;
}
.me-article-author {
  color: #a6a6a6;
  padding-right: 18px;
  font-size: 13px;
  cursor: pointer;
}
.me-article-author-img {
  width: 15px;
  height: 15px;
}
.me-article-author-avatar {
  width: 30px;
  height: 30px;
  vertical-align: text-bottom;
  border-radius: 50%;
}
.el-tag {
  margin-left: 6px;
}
.leftimg {
  /* width:11%;
  height:11%; */
  width: 100px;
  height: 90px;
  float: left;
  margin-right: 20px;
}
img {
  width: 100%;
  height: 100%;
}
.preimg {
  width: 700px;
  height: 90px;
  margin-bottom: 10px;
  display: flex;
}
</style>